package com.hzit.manager.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hzit.manager.entity.ContentEntity;
import com.hzit.manager.service.ContentService;
import com.hzit.common.utils.PageUtils;
import com.hzit.common.utils.R;



/**
 * 
 *
 * @author hbxfwf
 * @email 2568783935@gmail.com
 * @date 2023-06-06 15:58:41
 */
@RestController
@RequestMapping("manager/content")
public class ContentController {
    @Autowired
    private ContentService contentService;

    /**
     * 列表
     */
    @GetMapping("/list")
        public R list(@RequestParam Map<String, Object> params){
        PageUtils page = contentService.queryPage(params);

        return R.ok().put("page", page);
    }
    //查询广告列表
    @GetMapping("/findAll")
    public R findAll(){
        List<ContentEntity> contentEntityList = contentService.findAll();
        return R.ok().put("contentList",contentEntityList);
    }

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
        public R info(@PathVariable("id") String id){
		ContentEntity content = contentService.findById(id);

        return R.ok().put("content", content);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
        public R save(@RequestBody ContentEntity content){
		contentService.add(content);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
        public R update(@RequestBody ContentEntity content){
		contentService.update(content);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
        public R delete(@RequestBody String[] ids){
		contentService.delete(Arrays.asList(ids));

        return R.ok();
    }

}
